/*    */ package blockbuster.components.motion;
/*    */ 
/*    */ import blockbuster.components.BedrockComponentBase;
/*    */ import blockbuster.components.IComponentParticleInitialize;
/*    */ import blockbuster.emitter.BedrockEmitter;
/*    */ import blockbuster.emitter.BedrockParticle;
/*    */ import blockbuster.math.molang.MolangException;
/*    */ import blockbuster.math.molang.MolangParser;
/*    */ import blockbuster.math.molang.expressions.MolangExpression;
/*    */ import com.google.gson.JsonElement;
/*    */ import com.google.gson.JsonObject;
/*    */ 
/*    */ public class BedrockComponentInitialSpin
/*    */   extends BedrockComponentBase implements IComponentParticleInitialize {
/* 15 */   public MolangExpression rotation = MolangParser.ZERO;
/* 16 */   public MolangExpression rate = MolangParser.ZERO;
/*    */ 
/*    */ 
/*    */   
/*    */   public BedrockComponentBase fromJson(JsonElement elem, MolangParser parser) throws MolangException {
/* 21 */     if (!elem.isJsonObject()) return super.fromJson(elem, parser);
/*    */     
/* 23 */     JsonObject element = elem.getAsJsonObject();
/*    */     
/* 25 */     if (element.has("rotation")) this.rotation = parser.parseJson(element.get("rotation")); 
/* 26 */     if (element.has("rotation_rate")) this.rate = parser.parseJson(element.get("rotation_rate"));
/*    */     
/* 28 */     return super.fromJson((JsonElement)element, parser);
/*    */   }
/*    */ 
/*    */ 
/*    */   
/*    */   public JsonElement toJson() {
/* 34 */     JsonObject object = new JsonObject();
/*    */     
/* 36 */     if (!MolangExpression.isZero(this.rotation)) object.add("rotation", this.rotation.toJson()); 
/* 37 */     if (!MolangExpression.isZero(this.rate)) object.add("rotation_rate", this.rate.toJson());
/*    */     
/* 39 */     return (JsonElement)object;
/*    */   }
/*    */ 
/*    */ 
/*    */   
/*    */   public void apply(BedrockEmitter emitter, BedrockParticle particle) {
/* 45 */     particle.initialRotation = (float)this.rotation.get();
/* 46 */     particle.rotationVelocity = (float)this.rate.get() / 20.0F;
/*    */   }
/*    */ }


/* Location:              D:\fanbian\[D][龙之核心]DragonCore-2.6.0.3.jar!\blockbuster\components\motion\BedrockComponentInitialSpin.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */